import { apiDetailType, addingApiParamterConfig } from '@/pages/CodeTables/specification';
import { addDataApi } from '@/api/test/index';

const formState = reactive<apiDetailType>({
  apiAgreement: '',
  apiCode: '',
  apiDescribe: '',
  apiDirectoryCode: '',
  apiIpPort: '',
  apiName: '',
  apiPath: '',
  apiRequestMethod: '',
  apiRequestTimeout: '',
  apiSource: '',
  apiStatus: 0,
  createOrUpdateApiParamterConfigurationList: [],
});
// 输入参数数组

const paramList = ref<addingApiParamterConfig[]>([]);
const bodyList = ref<addingApiParamterConfig[]>([]);
const resultList = ref<addingApiParamterConfig[]>([]);
// const dataapiDrawer = ref<boolean>(false);
const addingData = async () => {
  formState.createOrUpdateApiParamterConfigurationList = [...paramList.value, ...bodyList.value, ...resultList.value];
  console.log(formState);
  const res = await addDataApi(formState);
  return res;
};
export function addingApiHooks() {
  return {
    formState,
    paramList,
    bodyList,
    resultList,
    addingData,
  };
}
